added some development tools
[windows-sources.git] / developer / Samples / NET 4.6 / WF_WCF_Samples / WCF / Scenario / TrustedFacade / VB / cleanup.bat
blob2c2f419eed9003fec5b421b1576bfa70d047df89
1 echo off
2 setlocal
3 call :setcomputername
4 ECHO ****************************************************************
5 ECHO WARNING:  This script will not remove service certificates on a 
6 ECHO           client machine from a cross machine run of this
7 ECHO           sample.
9 ECHO If you have run WCF samples that use Certs across machines, 
10 ECHO be sure to clear the service certs that have been installed in
11 ECHO the CurrentUser - TrustedPeople store.
12 ECHO To do this, use the following command:
14 ECHO "certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n <Fully Qualified Server Machine Name>"
16 ECHO For example:
18 ECHO "certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n server1.contoso.com"
19 call :cleancerts
20 DEL service.cer > NUL 2>&1
21 GOTO end
23 :cleancerts
24 REM cleans up certs from previous runs.
25 echo ****************
26 echo Cleanup starting
27 echo ****************
29 echo -------------------------
30 echo del client certs
31 echo -------------------------
32 certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n localhost
34 echo -------------------------
35 echo del service certs
36 echo -------------------------
37 certmgr.exe -del -r LocalMachine -s My -c -n localhost
38 certmgr.exe -put -r LocalMachine -s My -c -n %COMPUTER_NAME% computer.cer
39 IF %ERRORLEVEL% EQU 0 (
40    DEL computer.cer
41    echo ****************
42    echo "You have a certificate with a Subject name matching your Machine name."
43    echo "If this certificate is from a cross machine run of WCF samples press any key to delete it."
44    echo "Otherwise press Ctrl + C to abort this script."
45    pause
46    certmgr.exe -del -r LocalMachine -s My -c -n %COMPUTER_NAME%
49 :cleanupcompleted
50 echo *****************
51 echo Cleanup completed
52 echo *****************
54 GOTO :EOF
57 :setcomputername
58 REM Puts the Fully Qualified Name of the Computer into a variable named COMPUTER_NAME
59 for /F "delims=" %%i in ('cscript /nologo GetComputerName.vbs') do set COMPUTER_NAME=%%i
60 GOTO :EOF
62 :end